<template>
    <div class="leasedialog">
        <el-dialog title="" :visible.sync="dialogFormVisibleLease">
            <el-form :model="formlease">
                <el-form-item label="小区名称" :label-width="formLabelWidth">
                    <el-input v-model="formlease.Villagename" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="标题" :label-width="formLabelWidth">
                    <el-input v-model="formlease.title" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="面积" :label-width="formLabelWidth">
                    <el-input v-model="formlease.Size" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="总价" :label-width="formLabelWidth">
                    <el-input v-model="formlease.price" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="排序" :label-width="formLabelWidth">
                    <el-input v-model="formlease.sort" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="状态" :label-width="formLabelWidth">
                    <el-input v-model="formlease.state" autocomplete="off"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisibleLease = false">取 消</el-button>
                <el-button type="primary" @click="subminLease">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
export default {
  data () {
    return {
      formlease: {
        Villagename: '',
        title: '',
        Size: '',
        price: '',
        sort: '',
        state: ''
      },
      dialogFormVisibleLease: false,
      formLabelWidth: '80px'
    }
  },
  methods: {
    subminLease () {
      if (this.formlease.id) {
        this.$api.leaseEdit(this.formlease).then(res => {
          console.log(res)
          if (res.data.code === 1) {
            this.formlease = {
              Villagename: '',
              title: '',
              Size: '',
              price: '',
              sort: '',
              state: ''
            }
            this.$message.success('修改成功')
            this.$emit('update')
            this.dialogFormVisibleLease = false
          }
        })
      } else {
        this.$api.leaseAdd(this.formlease).then(res => {
          console.log(res)
          if (res.data.code === 1) {
            this.formlease = {
              Villagename: '',
              title: '',
              Size: '',
              price: '',
              sort: '',
              state: ''
            }
            this.$message.success(res.data.message)
            this.$emit('update')
            this.dialogFormVisibleLease = false
          }
        })
      }
    }
  }
}
</script>

<style>

</style>
